import { ref, computed, onMounted } from 'vue'
import { defineStore } from 'pinia'

export const mapStore = defineStore('map-store', () => {
  const selectedYear = ref('2020')
  const availableYears = ref([])
  const isClick = ref(false)
  const isScale = ref(false)
  const isRotate = ref(false)
  const isLove = ref(false)
  // 选中状态
  const isAir = ref(false)
  const isTemp = ref(false)
  const isRainy = ref(false)
  const isSun = ref(false)
  const isPM = ref(false)
  const isExtra = ref(true)
  const isGDP = ref(false)

  const isMouseClick = ref(false)
  // 画图
  const isEchart = ref(false)
  const option_rainy = ref(null)
  const option_temp = ref(null)
  const site_option = ref(null)
  const option_sun = ref(null)
  const kunming_rainy = ref([])
  const avg_temp = ref()
  const site_more = ref([])
  const kunming_sun = ref([])

  // 单独图表
  const ispmItem = ref(false)
  const pmItem_option = ref(null)
  const pmItem_option_low = ref(null)

  const israinyItem = ref(false)
  const rainyItem_option = ref(null)

  const istempItem = ref(false)
  const tempItem_option = ref(null)
  const tempItem_option_low = ref(null)

  const issunItem = ref(false)
  const sunItem_option = ref(null)

  // 拉框查询
  const searchLists = ref([])
  const isSearch = ref(false)
  const info = ref()

  // dgp弹窗
  const gdpCity = ref()
  const gdpYear = ref()
  const gdp = ref()

  // 权重
  const pmValue = ref()
  const tempValue = ref()
  const rainyValue = ref()
  const sunValue = ref()
  const heightValue = ref()
  const gdpValue = ref()
  const WeightList = [
    { pm: null },
    { temp: null },
    { rainy: null },
    { sun: null },
    { height: null },
    { gdp: null }
  ]

  onMounted(() => {
    for (let i = 2000; i < 2021; i++) {
      availableYears.value.push(`${i}`)
    }
  })
  return {

    isRotate,
    selectedYear,
    availableYears,
    isClick,
    isAir,
    isTemp,
    isRainy,
    isSun,
    isScale,
    isEchart,
    option_rainy,
    site_option,
    kunming_rainy,
    option_temp,
    avg_temp,
    site_more,
    option_sun,
    kunming_sun,
    searchLists,
    isSearch,
    info,
    isPM,
    isExtra,
    pmValue,
    tempValue,
    rainyValue,
    sunValue,
    heightValue,
    gdpValue,
    isLove,
    isGDP,
    isMouseClick,
    gdpCity,
    gdp,
    gdpYear,
    WeightList,
    // 单独图表
    // pm值
    ispmItem,
    pmItem_option,
    pmItem_option_low,
    // 降雨
    israinyItem,
    rainyItem_option,
    // 气温
    istempItem,
    tempItem_option,
    tempItem_option_low,
    // 光照
    issunItem,
    sunItem_option
  }
})
